package com.qmx.launcher.adapter;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.open.androidtvwidget.leanback.adapter.GeneralAdapter;
import com.open.androidtvwidget.leanback.mode.OpenPresenter;
import com.qmx.launcher.R;

import java.util.ArrayList;
import java.util.List;
import java.util.Vector;

/**
 * @author ChengXiangtong
 * @create 2018/10/12
 * @Describe
 */
public class SettingRecyclerViewPresenter extends OpenPresenter {

    private final List<String> labels;
    private GeneralAdapter mAdapter;
    public Vector<Boolean> vector = new Vector<>();

    public SettingRecyclerViewPresenter(String str[]) {
        this.labels = new ArrayList<String>(str.length);
        for (int i = 0; i < str.length; i++) {
            labels.add(str[i]);
            vector.add(false);
        }
    }

    @Override
    public void setAdapter(GeneralAdapter adapter) {
        this.mAdapter = adapter;
    }

    @Override
    public int getItemCount() {
        return labels.size();
    }

    @Override
    public int getItemViewType(int position) {
        return 0;
    }

    @Override
    public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_setting, parent, false);
        return new GridViewHolder(view);
    }

    @Override
    public void onBindViewHolder(ViewHolder viewHolder, int position) {
        GridViewHolder gridViewHolder = (GridViewHolder) viewHolder;
        TextView textView = gridViewHolder.tv;
        TextView option_params = gridViewHolder.option_params;
        ImageView arrow = gridViewHolder.iv;
        viewHolder.view.setTag(position);
        textView.setText(labels.get(position));
        option_params.setText(labels.get(position));
        //        System.err.println("onBindViewHolder===" + position);

    }

    public class GridViewHolder extends OpenPresenter.ViewHolder {

        public ImageView iv;
        public TextView tv;
        public TextView option_params;

        public GridViewHolder(View itemView) {
            super(itemView);
            iv = (ImageView) itemView.findViewById(R.id.tv_setting_option_arrow);
            tv = (TextView) itemView.findViewById(R.id.tv_setting_option_name);
            option_params = (TextView) itemView.findViewById(R.id.tv_setting_option_params);


        }

    }
}
